//
//  GMCheckHandleTool.m
//  News
//
//  Created by 雷国敏 on 16/9/17.
//  Copyright © 2016年 lieop. All rights reserved.
//

#import "GMCheckHandleTool.h"

@implementation GMCheckHandleTool
/**
 *  正则表达式 规定验证码格式
 *
 *  @param inputString <#inputString description#>
 *
 *  @return <#return value description#>
 */
+(BOOL)isVerifyNum:(NSString *)inputString
{
	NSString *regex = @"\\d{4}";
	return [GMCheckHandleTool isVerifyWithString:inputString regex:regex];
	
}

/**
 *  is Phone
 *
 *  @param inputString <#inputString description#>
 *
 *  @return <#return value description#>
 */
+(BOOL)isPhoneNumber:(NSString *)inputString
{
	NSString *regex = @"^1(3|5|7|8|4)\\d{9}";
	return [GMCheckHandleTool isVerifyWithString:inputString regex:regex];
}


/**
 *  isVerifyWithString
 *
 *  @param inputString <#inputString description#>
 *  @param regex       <#regex description#>
 *
 *  @return <#return value description#>
 */
+(BOOL)isVerifyWithString:(NSString *)inputString regex:(NSString *)regex
{
	NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
	return [pred evaluateWithObject:inputString ];
}



/**
 *  isEmail
 *
 *  @param email <#email description#>
 *
 *  @return <#return value description#>
 */
+ (BOOL)isEmail:(NSString *)email
{
	NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
	NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
	return [emailTest evaluateWithObject:email];
}

@end
